<div class="row-fluid">
    <div class="span12">
        <!-- BEGIN THEME CUSTOMIZER-->

        <!-- END THEME CUSTOMIZER-->
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <div style="clear:both; height:20px"></div>
        <ul class="breadcrumb">
            <li>
                <a href="<?php echo $this->Html->url(array("controller" => "home", "action" => "index")); ?>">Home</a>
                <span class="divider">/</span>
            </li>
            <li class="active">
                <a href="<?php echo $this->Html->url(array("controller" => "home", "action" => "master")); ?>">マスター</a>
                <span class="divider">/</span>
            </li>
            <li class="active">カメラのデータベース 

            </li>

        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
        <div class="row-fluid">
            <div class="span12">


                <!-- BEGIN EXAMPLE TABLE widget-->

                <div class="control-group">
                    <?php
                    echo $this->Form->create('Camera', array(
                        'inputDefaults' => array(
                            'div' => 'control-group',
                            'label' => array(
                                'class' => 'control-label'
                            ),
                            'wrapInput' => 'controls'
                        ),
                        'class' => 'form-horizontal'
                    ));
                    ?>
                    <?php
                    echo $this->Form->input('Camera.CustId', array(
                        'label' => array(
                            'text' => 'お客様名'
                        ),
                        'empty' => false,
                        'options' => $this->Common->listCustomer(true),
                        'class' => 'span4',
                        'id' => 'search_customer',
                        'required' => false
                    ));
                    ?>
                    <?php
                    echo $this->Form->input('Camera.BuildId', array(
                        'label' => array(
                            'text' => '物件名'
                        ),
                        'empty' => false,
                        'options' => $this->Common->listBulding(),
                        'class' => 'span4',
                        'id' => 'search_building'
                    ));
                    ?>
                    <?php
                    echo $this->Form->input('Camera.CamName', array(
                        'placeholder' => 'カメラ名',
                        'label' => array(
                            'text' => 'カメラ名'
                        ),
                        'class' => 'span4',
                        'type' => 'text',
                        'required' => false
                    ));
                    ?>
                    <?php
                    echo $this->Form->input('Camera.other', array(
                        'placeholder' => '他の項目で検索',
                        'label' => array(
                            'text' => '他の項目で検索'
                        ),
                        'class' => 'span4',
                        'type' => 'text',
                        'required' => false
                    ));
                    ?>
                    <div class="control-group required">
                        <label for="CameraName" class="control-label">
                            <button class="btn btn-success" type="submit">
                                <i class="icon-search icon-white"></i> 検索
                            </button>
                        </label>
                        <div class="controls required">
                        </div>
                    </div>
                <?php echo $this->Form->end(); ?>
                </div>
                <p>
                <div class="btn btn-warning"><a href="<?php echo $this->Html->url(array("controller" => "Camera", "action" => "add")); ?>" ><i class="icon-plus icon-white"></i> 新規カメラ</a></div>
                

                </p>
                <div class="widget red table-fixed-pixel">
                    <div class="widget-title">
                        <h4><i class="icon-reorder"></i> カメラ一覧</h4>
                        <span class="tools">
                            <a href="javascript:;" class="icon-chevron-down"></a>

                        </span>
                    </div>
                    <div class="widget-body">
                        <table class="table table-striped table-bordered " id="sample_1">
                            <thead>
                                <tr>
                                    
                                    <th style="min-width:8px;">No</th>
                                    <th style="min-width:70px;" class="text-center">ID</th>
                                    <th style="min-width:120px;" class="text-center">カメラ名</th>
                                    <th style="min-width:50px;" class="text-center">IPアドレス</th>
                                    <th style="min-width:50px;" class="text-center">ポート</th>
                                    <th class="text-center">カメラの機種名</th>

                                    <th style="min-width:80px;" class="text-center">解像度</th>
                                    <th width="66" class="text-center">フレーム数</th>
                                    <!--<th class="text-center">お客様ID</th>
                                    <th class="text-center">物件ID</th>-->
                                    <th style="min-width:80px;">&nbsp;</th>
                                    <th style="min-width:150px;width:150px;" >&nbsp;</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($cameras as $key =>$camera): ?>
                                    <tr class="odd gradeX">
                                        
                                        <td class="text-center"><?php echo $key+1;?></td>
                                        <td class="text-center"><?php echo $camera['Camera']['CamID'] ?></td>
                                        <td style="white-space: pre-line;overflow: hidden;text-overflow: ellipsis;max-width: 170px"><?php echo $camera['Camera']['CamName'] ?></td>
                                        <td class="text-center"><?php echo $camera['Camera']['UniIp'] ?></td>
                                        <td class="text-center"><?php echo $camera['Camera']['HttpPort'] ?></td>
                                        <td class="text-center"><?php echo $camera['Camera']['Model'] ?></td>

                                        <td class="text-center"><?php echo trim($camera['Camera']['Resolution'],'N') ?></td>
                                        <td class="text-right"><?php echo $camera['Camera']['FrameNo'] ?></td>
                                        <!--<td class="text-center"><?php //echo $camera['Customer']['CustId'] ?></td>
                                        <td class="text-center"><?php //echo $camera['Building']['BuildId'] ?></td>-->
                                        <td >
                                            <div  style="margin-top:3px"><i class="icon-map-marker"></i> 
                                                <a data-address="<?php echo $camera['Building']['BuildAddress'] ?>" class="view_map">View map</a>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="btn btn-primary">
                                                <a href="<?php echo $this->Html->url(array("controller" => "Camera", "action" => "edit", $camera['Camera']['Id'])); ?>" >
                                                    <i class="icon-pencil icon-white"></i> 編集
                                                </a>
                                            </div>&nbsp;
                                            <div class="btn btn-danger">
                                                <a href="<?php echo $this->Html->url(array("controller" => "Camera", "action" => "delete", $camera['Camera']['Id'])); ?>" >
                                                    <i class="icon-remove icon-white"></i> 削除
                                                </a>
                                            </div>
                                        </td>

                                    </tr>
                                <?php endforeach; ?>

                            </tbody>
                        </table>

                    </div>
                </div>
                <!-- END EXAMPLE TABLE widget-->


            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function () {
        //

        if ($("#search_customer").size() > 0) {
            getBuilding('<?php echo isset($_REQUEST['data']['Camera']['BuildId']) ? $_REQUEST['data']['Camera']['BuildId'] : "-1" ?>', 0);
        }
        $("#search_customer").on('change', function () {
            getBuilding(-1, 0);
        });

    });
</script>